<script setup lang="ts">
import {getSimpWordsAPI, reqPaList} from "./api";
import {onMounted, ref} from "vue";
import {paListType} from "./api/data/type.ts";

//定义展示的数组的变量，可将body里的数据赋予到paListType上
const body = {
  "applicant": "",
  "id": 0,
  "inventor": "翟懿奎",
  "openId": "",
  "openTime": "",
  "page": 1,
  "pageSize": 10,
  "patentName": "",
  "region": "",
  "time": "",
  "title": "",
  "type": "",
}


//初始化一个paList来存储数组，类型是paListType
const paList = ref<paListType[]>([])
//定义getPaList函数（按钮函数）来将reqPaList导出常量（内含resData）里的数据（body）传到result中
const getPaList = async () => {
  const result = await reqPaList(body)
  if (result.code === 200){
    //如果返回值是200（请求成功，则将resData里data中list的数据给到paList里）
    paList.value = result.data.list
  }else{

  }
}
// 定义响应式变量
const content = ref<string>('');

const getSimpWords = async () => {
  try {
    const response = await getSimpWordsAPI();
    if (response.code === 200) {
      // 如果返回值是200（请求成功），则将response里result中content的数据给到content里
      content.value = response.result.content;
    } else {
      console.log('请求失败，状态码：', response.code);
      console.log(response)
    }
  } catch (error) {
    console.error('请求过程中发生错误：', error);
  }
}
</script>

<template>
  <div>
  {{paList}}
  {{content}}
  <button @click="getSimpWords">请求专利</button>
    <!-- 遍历paList里的applicant数据 -->  
     </div>

</template>
